<!DOCTYPE html>
<html>

<head>
    <meta name="layout" content="main2"/>
    <g:set var="entityName" value="${message(code: 'user.label', default: 'user')}"/>
    <title>用户管理</title>
   %{-- <style>
    .table > tbody > tr > td {
        vertical-align: middle;
    }
    </style>--}%
</head>

<body>
<div class="main-body">
    <div class="page-wrapper">
        <!-- Page-header start -->
        <div class="page-header">
            <div class="page-header-title">
                <h4>所有用户</h4>
            </div>

            <div class="page-header-breadcrumb">
                <ul class="breadcrumb-title">
                    <li class="breadcrumb-item">
                        <a href="/salesDashboard/index">
                            <i class="icofont icofont-home"></i>
                        </a>
                    </li>
                    <li class="breadcrumb-item"><a href="#!">所有用户</a>
                    </li>
                </ul>
            </div>
        </div>
        <!-- Page-header end -->
        <!-- Page-body start -->
        <div class="page-body">
            <!-- Hover table card start -->
            <div class="card">
                <div class="card-header">
                    <h5>所有用户</h5>

                    <div class="card-header-right">
                        <g:link action="create"><i class="ion-plus"></i> 新增</g:link>
                    </div>
                </div>

                <div class="card-block">

                    <div class="table-responsive dt-responsive">
                        <div id="dom-jqry_wrapper" class="dataTables_wrapper dt-bootstrap4">

                            <g:form method="POST" action="searchUser">
                                <div class="row m-0">
                                    <div class="col-md-10 p-l-0">
                                        <div id="dom-jqry_filter" class="text-left">
                                            <label class="block">
                                              <div class="form-group row">
                                                <div class="col-md-3">
                                                  <input type="text" class="form-control" placeholder="员工姓名"
                                                  name="fullName"
                                                  id="fullName"
                                                  value="${params?.fullName}">
                                                </div>
                                                <div class="col-md-3">
                                                  <input type="text" class="form-control" placeholder="所在城市"
                                                  name="city"
                                                  id="city"
                                                  value="${params?.city}">
                                                </div>
                                                <div class="col-md-3">
                                                  <!-- <input type="text" class="form-control" placeholder="所属部门"
                                                  name="department"
                                                  id="department"
                                                  value="${params?.department}"> -->
                                                  <g:select class="form-control" name="department" id="department" optionValue="name"
                                                  optionKey="name"
                                                  from="${com.next.Department.list()}" value="${params?.department}"
                                                  noSelection="${['': '所属部门']}"/>
                                                </div>
                                              </div>
                                            </label>
                                        </div>
                                    </div>

                                    <div class="col-md-2 p-r-0 dt-buttons text-right">

                                        <button class="btn btn-inverse btn-sm btn-squeare" type="submit"><i
                                                class="fa fa-search"></i></button>
                                        <button class="btn btn-inverse btn-sm btn-squeare" type="button"
                                                id="resetBtn"><i class="fa fa-refresh"></i></button>

                                    </div>
                                </div>
                            </g:form>

                            <table class="table table-striped  table-bordered table-hover">
                                <thead>
                                <tr>
                                    <g:sortableColumn property="fullName"
                                                      title="${message(code: 'user.fullName.label', default: '员工姓名')}"/>
                                    <g:sortableColumn property="department"
                                                      title="${message(code: 'user.department.label', default: '所在部门')}"/>

                                    <g:sortableColumn property="reportTo"
                                                      title="${message(code: 'user.reportTo.label', default: '汇报对象')}"/>
                                    <g:sortableColumn width="20%" property="account"
                                                      title="${message(code: 'user.account.label', default: '重置密码')}"/>
                                </tr>
                                </thead>
                                <tbody>
                                <g:each in="${userList}">
                                    <tr>
                                        <td>
                                            <g:link action="show" id="${it?.id}"
                                                    class="firstTd">${it?.fullName}</g:link>
                                        </td>
                                        <td>${it?.department}</td>
                                        <td>${it?.reportTo}</td>
                                        <td width="20%">
                                            <g:form controller="user" action="resetPassword">
                                                <div class="input-group">
                                                    <input type="hidden" name="destination" value="user">
                                                    <input type="hidden" name="user" value="${it?.id}">
                                                    <input class="form-control" type="password" name="password"
                                                           autocomplete="off" style="height: 28px">
                                                    <span class="input-group-addon" style="padding: 0 12px">
                                                        <button class="btn btn-primary btn-mini"
                                                                type="submit">提交</button>
                                                    </span>
                                                </div>

                                            </g:form>
                                        </td>
                                    </tr>
                                </g:each>
                                </tbody>
                            </table>

                            <div class="dataTables_paginate">
                                <div class="pagination">
                                    <g:paginate total="${userCount ?: 0}" params="${params}"/>
                                </div>
                            </div>
                        </div>

                    </div>

                </div>
            </div>
            <!-- Hover table card end -->
        </div>

        <!-- Page-body end -->

    </div>
</div>
<g:javascript>
    $(function () {
        $("#resetBtn").click(function () {
            $("#fullName").val("");
            $("#department").val("");
            $("#select2-department-container").text("所属部门");
            $("#city").val("");
        })
    });

</g:javascript>
</body>

</html>
